{{- range $key, $value := .CandiVersionMap.k8s }}
  {{- $version := toString $key }}
  {{- if $value.ccm.openstack }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $version | replace "." "-" }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
  add: /src/openstack-cloud-controller-manager
  to: /bin/openstack-cloud-controller-manager
  before: setup
docker:
  ENTRYPOINT: ["/bin/openstack-cloud-controller-manager"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    {{- if semverCompare ">=1.29" $version }}
from: {{ $.Images.BASE_GOLANG_21_BULLSEYE }}
    {{- else if semverCompare ">=1.27" $version }}
from: {{ $.Images.BASE_GOLANG_20_BUSTER }}
    {{- else if semverCompare ">=1.25" $version }}
from: {{ $.Images.BASE_GOLANG_19_BUSTER }}
    {{- end }}
git:
- add: /{{ $.ModulePath }}modules/030-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
  to: /patches
  stageDependencies:
    install:
      - '**/*'
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  beforeInstall:
  - apt update
  - apt install git mercurial rsync patch -y
  install:
  - mkdir /src
  - wget https://github.com/kubernetes/cloud-provider-openstack/archive/{{ $value.ccm.openstack }}.tar.gz -O - | tar -xz --strip-components=1 -C /src/
  - cd /src
  - test -d /patches/{{ $version }} && for patchfile in /patches/{{ $version }}/*.patch ; do patch -p1 < ${patchfile}; done
  - make VERSION={{ $value.ccm.openstack }} GIT_VERSION={{ $value.ccm.openstack }} openstack-cloud-controller-manager
  {{- if semverCompare "<1.27" $version }}
  - mv /src/openstack-cloud-controller-manager-amd64 /src/openstack-cloud-controller-manager
  {{- end }}
  - chown 64535:64535 /src/openstack-cloud-controller-manager
  - chmod 0755 /src/openstack-cloud-controller-manager
  {{- end }}
{{- end }}
